<template>
	<view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				code: ''
			}
		},
		onLoad(params) {

			console.log("index");
			console.log(params);
			console.log(location);
			if (location.search.indexOf('code=') > -1) {
				this.code = location.search.substring(location.search.indexOf('code=') + 5, location.search.indexOf("&", location.search
					.indexOf('code=') + 5));

				console.log(this.code);

				this.$sendhttp(getApp().globalData.tokenurl + "?code=" + this.code, {}, function(data) {
					uni.setStorageSync("token", data.token);
					uni.setStorageSync("userinfo", data.userinfo);
					if (params.t == 'a') {
						uni.redirectTo({
							url: '/pages/login/login'
						})
					} else {
						uni.redirectTo({
							url: '/pages/add-member/add-member?oid='+params.oid+'&oname='+params.oname
						})
					}
				});
			} else {
				this.$showModal("没有code");
			}
		}
	}
</script>

<style>

</style>
